#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
struct node{
	string start,stop;
};
bool cmp(node a,node b){
	return a.stop!=b.stop? a.stop<b.stop : a.start>b.start;
}
int main(){
	int n;
	cin >> n;
	vector<node> list(n);
	for(int i = 0;i < n;i++){
		cin >> list[i].start >> list[i].stop;
	}
	sort(list.begin(),list.end(),cmp);
	string now = "00:00:00";
	int count = 0;
	for(int i = 0;i < n;i++){
		if(now<=list[i].start){
			count++;
			now = list[i].stop;
		}
	}
	cout << count;
	return 0;
}
